const TARO_ENV = process.env.TARO_ENV

const pages = ['pages/index/index', 'pages/limited/index', 'pages/my/index/index']

const tabBarList = [{pagePath: 'pages/index/big', text: ''}, {pagePath: 'pages/index/index', text: ''}, {pagePath: 'pages/my/index/index', text: ''}]

const commonPackages = [
  'news/list',
  // 'news/detail',
  // 'label/label',
  // 'polymerize/list',
  // 'limited/list',
  // 'limited/index',
  // 'limited/detail',
  // 'scenic/index',
  // 'scenic/detail',
  // 'scenic/label',
  // 'scenic/scenicIndex',
  // 'tourist-line/index',
  // 'tourist-line/detail',
  // 'tourist-line/label',
  // 'hotel/list',
  // 'hotel/index',
  // 'hotel/detail',
  // 'hotel/label',
  // 'hotel/outlands',
  // 'hotel/city',
  // 'search/search',
  // 'search/searchList',
  // 'search/search-new',
  // 'search/label',
  // 'custom/index'
]

const mainPackages = [
  'login/login',
  'order/confirm',
  'order/success',
  'order/combination',
  'my/face/face',
  'my/face/example',
  'order/detail',
  'order/order',
  'site/partner',
  'recommend-list/recommend-list',
  'my/setting/setting',
  'webview/index',
]

const payPackages = ['emptyPage']

const moviePackages = ['emptyPage']

const wordsPackages = ['emptyPage']

const pagePackages = [
  'market/scenic/detail',
  'market/toursline/detail',
  'market/hotel/detail',
  'index',
  'my/seller-apply/seller-apply',
  'my/seller-apply-vip/seller-apply-vip',
  'site/index',
  'module/hongbao/zhuli',
  'market/product/detail',
  'qianggou/index/index',
  'qianggou/detail/detail',
  'market/scenic/index',
  'market/hotel/index',
  'market/product/index',
  'market/toursline/index',
  'my/news/index',
  'my/news/url',
  'partner/apply',
  'label/list',
  'my/index/index',
  'offline/index'
]

const otherPackages = [
  'debug/open',
  'store/store',
  'agreement/interests',
  'limited/index',
  'shop/picture',
  'shop/details',
  'shop/list',
  'shop/info',
  'collection/list',
  'siteList/index',
  'lineform/index',
  'page/middlePage',
  'meal/index',
  'agreement/service',
  'category-list/category-list',
  'tech-support/tech-support',
  'city-labels/city-labels',
  'select-city/select-city',
  'address/index',
  'address/detail',
  'address/list',
  'address/addcontact',
  'scenicCard/index',
  'agreement/lineService'
]

const distributorPackages = ['contact/contact', 'meals/list', 'meals/detail', 'order/lianorder']
if (TARO_ENV === 'weapp' || TARO_ENV === 'h5') {
  pages.unshift('pages/index/big')
  // commonPackages.push(...['product/detail', 'product/index', 'redbag/redbag', 'redbag/help','evaluation/index', 'local-life/index', 'local-life/list','limited/localdetail', 'limited/localdetailali','seckill/index', 'seckill/detail', 'tourist-line/list', 'live-player/list', 'live-player/playback', 'live-player/detail','jump/other','middle-page/list','distributor/invite/invite', 'distributor/invite/group', 'distributor/invite/register', 'distributor/invite/join','tourist-line/accompany', 'tourist-line/accompany_list','group/detail', 'group/play'])
  mainPackages.push(...['coupon/index', 'coupon/list', 'coupon/detail', 'coupon/coupon-goods', 'my/redbag/list', 'my/integral/integral', 'my/integral/rules', 'order/place', 'shopcar/index', 'order/evaluation', 'order/pay', 'order/payali', 'my/member/interests', 'my/member/order', 'coupon/exchangecode', 'order/lianorder', 'tyy/reclaimer', 'tyy/cooperation', 'tyy/custommade', 'productDetail/index', 'businessDetail/index', 'productForm/edit', 'productForm/business', 'productForm/index', 'businessList/index', 'productList/index', 'lectureRoom/index', 'lectureRoom/detail', 'lectureRoom/list', 'lectureRoom/news/index', 'lectureRoom/news/url', 'order/userCoinBalanceList', 'order/pcpay', 'order/Mdetail', 'order/logistics', 'order/promotionOrder', 'order/invoice/invoice', 'order/invoice/addLookUp', 'order/invoice/send-email', 'order/invoice/look-up-detail', 'order/invoice/invoice-detail', 'order/aftersales/type', 'order/aftersales/refund', 'order/aftersales/orderdetail', 'order/aftersales/logistics', 'supplier/check-ticket', 'supplier/order-ticket', 'supplier/ticket-record', 'supplier/ticket-summary', 'supplier/manage-appointment', 'my/cancelAfterVerification/index', 'my/requestInvoice/list', 'my/requestInvoice/info', 'my/requestInvoice/downlode', 'my/supplier/index', 'my/marketPerformance/index', 'my/businessPerformance/index', 'my/cancelAfterManagement/index', 'my/cancelAfterManagement/add', 'my/distributor/index', 'my/guidePage/anovice', 'my/guidePage/newbieTask', 'my/newbieTask/index'])
  payPackages.push(...['index', 'inPay', 'success', 'pcpay'])
  pagePackages.push(...['my/teamappoint/supplier/list', 'my/teamappoint/site/list', 'my/teamappoint/splist', 'my/teamappoint/order/detail'])
  moviePackages.push(...['index', 'Mlist', 'Clist', 'Minfo', 'Cinfo', 'Morder', 'seats'])
  wordsPackages.push(...['list', 'detail', 'preview', 'downlode', 'share'])
  otherPackages.push(...['evaluation/index', 'integral/recording', 'error/index', 'select-city/select-city-local-ali', 'aliLocalLife/local-life/index', 'select-city/select-city-local', 'aliLocalLife/productList', 'aliLocalLife/productInfo', 'aliLocalLife/businessList', 'aliLocalLife/businessInfo', 'aliLocalLife/supplier/list', 'aliLocalLife/supplier/index', 'debug/index', 'select-city/movie-city', 'address/h5map', 'wifi/index', 'wifi/update', 'wifi/connect', 'buy-order/money', 'buy-order/buyorder', 'buy-order/recording', 'buy-order/billingdetail', 'teamappoint/success', 'teamappoint/info', 'teamappoint/addcontact', 'teamappoint/formGuide', 'appointment/my', 'appointment/list', 'appointment/empty', 'appointment/order', 'appointment/detail', 'appointment/siteList', 'appointment/exchangeCode', 'customerQRjustShow/index', 'mapNavigation/index', 'mapNavigation/Notice', 'mapNavigation/List', 'mapNavigation/InnerNavigate', 'mapNavigation/webview', 'site/order', 'site/order-detail', 'site/writeOffStatistics', 'map/index', 'travelTips/travelTips', 'carRental/index', 'carRental/list', 'carRental/outletsDetail', 'carRental/detail', 'my/customer', 'my/myInvite', 'my/customerInfo', 'my/accountConsolidation'])
  distributorPackages.push(...['wallet/pay', 'wallet/supplier', 'wallet/ruleSupplier', 'wallet/supplierrecord', 'profile/profile', 'poster/poster', 'promotioncode/promotioncode', 'wallet/debts', 'wallet/debtsDetail', 'wallet/wallet', 'wallet/rank', 'wallet/log', 'wallet/recharge', 'wallet/rule', 'wallet/record', 'wallet/alipay', 'wallet/cash', 'member/member', 'ranking/ranking', 'list/list', 'list/list2', 'list/children', 'list/adjust-rate', 'order/order', 'order/detail', 'order/reseller-order', 'report/index', 'report/detail/estimatedIncome', 'report/detail/promotionOrder'])
}

if (TARO_ENV === 'tt') {
  tabBarList.splice(0, 1)
  pages.push('pages/payReplaceZJpay/index')
  mainPackages.push(...['order/appointmentBill', 'order/appointmentCancel', 'order/appointmentDetail', 'order/appointmentMake'])
  payPackages.push(...['payReplaceZJpay/index'])
}

export default defineAppConfig({
  pages,
  subPackages: [
    {
      root: 'common',
      pages: commonPackages
    },
    // {
    //   root: 'main',
    //   pages: mainPackages
    // },
    // {
    //   root: 'pay',
    //   pages: payPackages
    // },
    // {
    //   root: 'page',
    //   pages: pagePackages
    // },
    // {
    //   root: 'movie',
    //   pages: moviePackages
    // },
    // {
    //   root: 'words',
    //   pages: wordsPackages
    // },
    // {
    //   root: 'other',
    //   pages: otherPackages
    // },
    // {
    //   root: 'distributor',
    //   pages: distributorPackages
    // }
  ],
  // preloadRule: {
  //   'pages/index/index': {
  //     "network": "all",
  //     "packages": ["common/"]
  //   },
  //   'pages/my/index/index': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   },
  //   'common/limited/detail': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   },
  //   'common/product/detail': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   },
  //   'common/scenic/detail': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   },
  //   'common/tourist-line/detail': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   },
  //   'common/hotel/detail': {
  //     "network": "all",
  //     "packages": ["main/"]
  //   }
  // },
  window: {
    navigationBarTitleText: '',
    navigationBarTextStyle: 'black',
    navigationBarBackgroundColor: '#ffffff',
    backgroundTextStyle: 'light',
    backgroundColor: '#ffffff'
  },
  lazyCodeLoading: "requiredComponents",
  tabBar: {
    custom: true,
    list: tabBarList
  },
  usingComponents: TARO_ENV === 'weapp' ? {
    'customTabBar': './custom-tab-bar/index'
  } : {},
  networkTimeout: {
    request: 10000
  },
  permission: {
    'scope.userLocation': {
      'desc': '您的位置信息将用于商品推荐展示'
    }
  },
  plugins: TARO_ENV === 'weapp' ? {
    tencentvideo: {
      version: "2.0.10",
      provider: "wxa75efa648b60994b"
    }
  } : {}
})
